package amigos;

import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexManager;

import aterrizar.Usuario;
import daos.SessionManager;
import servicios.Operation;

public class RegistrarUsuario implements Operation<Node> {
	
	public Usuario user;
	
	public RegistrarUsuario(Usuario user){
		this.user = user;
	}

	public Node execute() {
		Node user = SessionManager.getGraphSession().createNode();
		user.setProperty("Nombre", this.user.getNombre());
		user.setProperty("Apellido", this.user.getApellido());
		user.setProperty("Email", this.user.getEmail());
		user.setProperty("UserName", this.user.getNombreDeUsuario());
		IndexManager index = SessionManager.getGraphSession().index();
		Index<Node> forNodes = index.forNodes("users");
		forNodes.add(user, "UserName", this.user.getNombreDeUsuario());
	
		
		return user;
		
		
		
	}

}
